package com.rzgeo.rzmaplib.model;

import android.content.Context;

import com.rzgeo.rzmaplib.util.RmlUtil;

import java.io.File;

/**
 * Created by zhanghang on 2018/1/20.
 */

public class RmlAppMainDir {

    public final File mainSysFolder;
    public final RmlPrjsSet prjsSet;
    public final File shareFolder;
    public final File slideFolder;

    public final File tempFolder;
    public final File templateFolder;

    RmlAppMainDir(Context context,File mainSysFolder) {
        this.mainSysFolder = mainSysFolder;
        File datasFolder = RmlUtil.Files.join(mainSysFolder, "works");
        this.shareFolder = RmlUtil.Files.join(mainSysFolder,"share");
        this.tempFolder = RmlUtil.Files.join(mainSysFolder,"temp");
        this.templateFolder = RmlUtil.Files.join(mainSysFolder,"template");
        this.slideFolder = RmlUtil.Files.join(mainSysFolder,"system");

        File[] files = new File[]{mainSysFolder,
                datasFolder,
                shareFolder,
                tempFolder,
                templateFolder,
                slideFolder
        };
        for(File f:files){
            if(!f.exists()){
                if(!f.mkdirs())
                    RmlUtil.Tip.Alert(context,"创建系统文件夹失败，请同意所有权限，并重启程序。");
            }
        }

        prjsSet=new RmlPrjsSet(datasFolder, context);
    }
}
